﻿/*
 * PsTFS is a set of PowerShell commands to manage and use Team Foundation Server. PowerShell 
 * effectiveness is combined with the power of TFS API to maximizes TFS capabilities.
 * 
 * Creator : Choulant Noham
 * Mail : choulant@gmail.com
 * Blog : http://choulant.blogspot.com
 * 
 */

using System.Management.Automation;
using Microsoft.TeamFoundation.Client;
using PsTFS.Methodes;
using PsTFS.Objects;

namespace PsTFS.Commandes.Remove
{
    /// <summary>
    /// Permet de supprimer un utilisateur
    /// </summary>
    [Cmdlet(VerbsCommon.Remove, "ProjectMember")]
    public class Remove_ProjectMember : PsCmdlet
    {
        /// <summary>
        /// Lancement du processus
        /// </summary>
        protected override void ProcessRecord()
        {
            Methode.RemoveUserToRole(UserName, Roles, Context.Instance.Project.Name);
        }
        /// <summary>
        /// Permet d'informer la fin de la commande
        /// </summary>
        protected override void EndProcessing()
        {
            Log.AddLog(null, "Remove-ProjectMember is end");
            base.EndProcessing();
        }

        /// <summary>
        /// Object contenant Team Foundation Server
        /// </summary>
        [Parameter(Position = 0)]
        public TfsTeamProjectCollection TFS
        {
            set { Context.Instance.TFS = value; }
        }
        
        /// <summary>
        /// Nom du label
        /// </summary>
        [Parameter(Position = 1)]
        public string ProjectName
        {
            set { Context.Instance.Project = Methode.GetProject(value); }
        }

        /// <summary>
        /// Nom du membre à supprimer
        /// </summary>
        [Parameter(Position = 2, Mandatory = true)]
        [ValidateNotNullOrEmpty]
        public string UserName { get; set; }

        /// <summary>
        /// Rôle
        /// </summary>
        [Parameter(Position = 3, Mandatory = true)]
        [ValidateNotNullOrEmpty]
        public string Roles { get; set; } 
    }
}


